﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DemoApp
{
    public partial class OptionsDialog : Form
    {
        public OptionsDialog()
        {
            InitializeComponent();

            this.textBox1.Text = Properties.Settings.Default.APIKey;
            this.textBox2.Text = Properties.Settings.Default.SecretKey;
            this.textBox3.Text = Properties.Settings.Default.PublisherID;
            this.checkBox1.Checked = Properties.Settings.Default.EnforceSigning;
            this.textBox4.Text = Properties.Settings.Default.Username;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // OK/Save

            this.DialogResult = DialogResult.OK;

            Properties.Settings.Default.APIKey = this.textBox1.Text;
            Properties.Settings.Default.SecretKey = this.textBox2.Text;
            Properties.Settings.Default.PublisherID = this.textBox3.Text;
            Properties.Settings.Default.EnforceSigning = this.checkBox1.Checked;
            Properties.Settings.Default.Username = this.textBox4.Text;
            if (!string.IsNullOrEmpty(this.textBox5.Text))
            {
                Properties.Settings.Default.Password = this.textBox5.Text;
            }
            Properties.Settings.Default.Save();

            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;

            this.Close();
        }
    }
}
